<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="shortcut icon" href="./img/logo.png" type="image/x-icon">
    <link rel="stylesheet" href="css/user_wzt.css">
    <!-- <script src="js/jquery.min.js"></script> -->
    <script src="js/zepto.js"></script>
    <title>个人中心</title>
</head>
<body>
    <div class="content">
        <!-- 上半部分 -->
        <div class="user_comp">
            <!-- 头部 -->
            <div class="header">
                <div class="flexbox left">
                    <a href="index_wzt.html" class="header_back"></a>
                    <a href="#" class="city_wrap">
                        <span class="switch_city">
                            <em class="city" id="city">合肥</em>
                            <i class="icon_pull"></i>
                        </span>
                    </a>
                </div>
                <a href="#" class="logo_wrap center">
                    <span class="logo">快捷找房</span>
                </a>
                <a href="login_wzt.html" class="my right ua">
                    <i class="icon_user"></i>
                </a>
            </div>
            <!-- 头像 -->
            <img src="img/user/user.png" alt="" class="img_head">
            <!-- 登录注册 -->
            <div class="user_num" id="user">
                <a href="login_wzt.html">登录</a>
                <a href="registered_wzt.html">注册</a>
            </div>
        </div>
        <!-- 下半部分 -->
        <div class="page_list">
            <ul id="house_ul">
                <li> 
                    <a href="user_house.html?n=house" id="hou">我关注的房源</a>
                    <span class="list_item"></span>
                    <span class="right_arrow"></span>
                </li>
                <li> 
                    <a href="user_house.html?n=xiao" id="xiao">我关注的小区</a>
                    <span class="list_item item_focus_community"></span>
                    <span class="right_arrow"></span>
                </li>
                <li> 
                    <a href="user_house.html?n=new" id="new">我关注的新房</a>
                    <span class="list_item item_focus_new_house"></span>
                    <span class="right_arrow"></span>
                </li>
                <li> 
                    <a href="user_rent.html" id="rent">我关注的租房</a>
                    <span class="list_item item_focus_zu_house"></span>
                    <span class="right_arrow"></span>
                </li>
                <li> 
                    <a href="user_coupons.html" id="youhui">我的租房优惠券</a>
                    <span class="list_item item_focus_zu_youhui"></span>
                    <span class="right_arrow"></span>
                </li>
            </ul>
        </div>
        <!-- 退出登录 -->
        <div class="logout" id="err">退出登录</div>
    </div>
    <script>
        //自适应字体大小
        (function () {
            function w() {
                var all = document.documentElement;
                var test = all.getBoundingClientRect().width;
                rem = test / 26;
                all.style.fontSize = rem + 'px'
            }
            w();
            window.addEventListener("resize", function () {
                w()
            }, false)
        })();
        // 判断是否登录
        var name=sessionStorage.name;
        if(name=="undefined"){
            $(".logout").hide()
            $("#house_ul li a").click(()=>{
                window.location.href="login.html"
            })
        }else{
            $("#user a").hide()
            $("#user").prepend(`
                <div>欢迎你，${name}</div>
            `)
            $(".logout").show()
            // 跳转页面
            $("#hou").click(()=>{
                window.location.href="user_house.html?n=house"
            })
            $("#xiao").click(()=>{
                window.location.href="user_house.html?n=xiao"
            })
            $("#new").click(()=>{
                window.location.href="user_house.html?n=new"
            })
            $("#youhui").click(()=>{
                window.location.href="user_coupons.html"
            })
            $("#rent").click(()=>{
                window.location.href="user_rent.html"
            })
        }
        // 退出登录
        $(".logout").click(()=>{
            sessionStorage.removeItem("name")
            $("#user a").show()
            $(".logout").hide()
            $("#user div").hide()
        })
        // 城市改变
        $("#city").click(()=>{
            window.location.href="city.html"
        })
        if(sessionStorage.city){
            $("#city").html(sessionStorage.city)
        }else{
            $("#city").html("合肥")
        }

        if(sessionStorage.getItem('login')){
            $('#user').css({display:'none'})
        }
    </script> 
    
</body>
</html>